package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.Company;
import com.ruoyi.system.service.ICompanyService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Easy;
import com.ruoyi.system.service.IEasyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 易告知Controller
 * 
 * @author ruoyi
 * @date 2023-03-04
 */
@RestController
@RequestMapping("/system/easy")
public class EasyController extends BaseController
{
    @Autowired
    private IEasyService easyService;

    private ICompanyService iCompanyService;
    /**
     * 查询易告知列表
     */
    @PreAuthorize("@ss.hasPermi('system:easy:list')")
    @GetMapping("/list")
    public TableDataInfo list(Easy easy)
    {
        startPage();
        List<Easy> list = easyService.selectEasyList(easy);
        return getDataTable(list);
    }

    /**
     * 导出易告知列表
     */
    @PreAuthorize("@ss.hasPermi('system:easy:export')")
    @Log(title = "易告知", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Easy easy)
    {
        List<Easy> list = easyService.selectEasyList(easy);
        ExcelUtil<Easy> util = new ExcelUtil<Easy>(Easy.class);
        util.exportExcel(response, list, "易告知数据");
    }

    /**
     * 获取易告知详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:easy:query')")
    @GetMapping(value = "/{easyId}")
    public AjaxResult getInfo(@PathVariable("easyId") Long easyId)
    {
        return success(easyService.selectEasyByEasyId(easyId));
    }

    /**
     * 新增易告知
     */
    @PreAuthorize("@ss.hasPermi('system:easy:add')")
    @Log(title = "易告知", businessType = BusinessType.INSERT)
    @PostMapping
    public void add(@RequestBody Easy easy)
    {
        easyService.insertEasy(easy);
    }

    /**
     * 修改易告知
     */
    @PreAuthorize("@ss.hasPermi('system:easy:edit')")
    @Log(title = "易告知", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Easy easy)
    {
        return toAjax(easyService.updateEasy(easy));
    }

    /**
     * 删除易告知
     */
    @PreAuthorize("@ss.hasPermi('system:easy:remove')")
    @Log(title = "易告知", businessType = BusinessType.DELETE)
	@DeleteMapping("/{easyIds}")
    public AjaxResult remove(@PathVariable Long[] easyIds)
    {
        return toAjax(easyService.deleteEasyByEasyIds(easyIds));
    }
}
